package cn.cycleif.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;

public enum InboxTypeEnum implements IEnum<Integer> {

  ALL(0, "全部", "ALL"),
  POSTS(1, "提问", "POSTS"),
  VOTES(2, "投票", "VOTES"),
  OTHER(3, "其他", "OTHER"),
  ;

  private final int    code;
  @JsonValue
  private final String desc;
  private final String sign;

  InboxTypeEnum(int code, String desc, String sign) {
    this.code = code;
    this.desc = desc;
    this.sign = sign;
  }

  public static InboxTypeEnum fromCode(Integer code) {
    for (InboxTypeEnum statusEnum : InboxTypeEnum.values()) {
      if (statusEnum.getValue()
                    .equals(code)) {
        return statusEnum;
      }
    }
    return null;
  }

  @Override
  public Integer getValue() {
    return this.code;
  }
}